﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sac.Data;
using System.Configuration;
using System.Data;

namespace Sac.Web
{
    public class GetCacheValue
    {
        OledbPro oledb;

        public GetCacheValue()
        {
            string ConnStr = ConfigurationManager.AppSettings["access"].ToString();
            oledb = new OledbPro(ConnStr);
        }

        /// <summary>
        /// 根据关系数据库中缓存的ID获取缓存的实时值
        /// </summary>
        /// <param name="CacheId">缓存Id</param>
        /// <returns></returns>
        public double GetCacheDataById(string CacheId)
        {
            string SqlGetData = "select cache_value from REAL_VALUE_CACHE where CACHE_NAME='" + CacheId + "'";
            DataRow dr = oledb.GetDataRow(SqlGetData);
            if (dr != null)
            {
                return Convert.ToDouble(dr[0]);
            }
            else
            {
                return 0;
            }
        }
    }
}
